﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Program06
{
    class HalfPrice
    {
        #region 需求
        //有些商品是单价打折
        //有些是总价满减
        //有些是第二个半价
        //……
        #endregion

        private Sale Sale { get; set; }

        //第几个半价
        private int _determine;
        public int Determine 
        { 
            get { return _determine; } 
            set { _determine = value < 0 ? 0 : value; } 
        }

        public HalfPrice() { }
        public HalfPrice(Sale sale)
        {
            this.Sale = sale;
        }

        /// <summary>
        /// 传入一个商品的单价，计算第二个半价后的总价
        /// </summary>
        /// <param name="price"></param>
        public void Half(double price)
        {
            if (Sale.Count <= Determine)
            {
                Sale = new Sale(price * 0.75) { Count = Sale.Count };
                Console.WriteLine(Sale);
            }
        }
    }
}
